package com.yanqu.road.logic.activity.zhenhuan;

import com.yanqu.road.entity.activity.zhenhuan.ZhenHuanPromotionInfo;
import com.yanqu.road.entity.activity.zhenhuan.firstProcess.UserZhenHuanFirstProcessData;
import com.yanqu.road.entity.activity.zhenhuan.secondProcess.GameZhenHuanFinishPartyData;
import com.yanqu.road.entity.activity.zhenhuan.secondProcess.UserZhenHuanGoingOutData;
import com.yanqu.road.entity.activity.zhenhuan.secondProcess.UserZhenHuanPartyHistoryData;
import com.yanqu.road.entity.activity.zhenhuan.secondProcess.UserZhenHuanSecondProcessData;
import com.yanqu.road.pb.activity.ZhenHuanProto;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

public class ZhenHuanPb {
    public static ZhenHuanProto.ZhenHuanFirstProcessUserSyncMsg.Builder parseUserMsg(UserZhenHuanFirstProcessData userData) {
        ZhenHuanProto.ZhenHuanFirstProcessUserSyncMsg.Builder builder = ZhenHuanProto.ZhenHuanFirstProcessUserSyncMsg.newBuilder();
        builder.setActivityId(userData.getActivityId());
        builder.setIsWorship(userData.isWorship());
        builder.setPower(userData.getPower());
        builder.setScore(userData.getScore());
        builder.setSpecialAmount(userData.getSpecialAmount());
        return builder;
    }

    public static ZhenHuanProto.ZhenHuanPromotionTemp.Builder parsePromotionTemp(ZhenHuanPromotionInfo promotionInfo) {
        ZhenHuanProto.ZhenHuanPromotionTemp.Builder builder = ZhenHuanProto.ZhenHuanPromotionTemp.newBuilder();
        builder.setUserId(promotionInfo.getUserId());
        builder.setRank(promotionInfo.getRank());
        builder.setValue(promotionInfo.getValue().toString());
        builder.setParam(promotionInfo.getParam());
        builder.setLastUpdateTime(promotionInfo.getLastUpdateTime());
        return builder;
    }

    public static List<ZhenHuanProto.ZhenHuanPromotionTemp> parsePromotionTempList(List<ZhenHuanPromotionInfo> infoList) {
        List<ZhenHuanProto.ZhenHuanPromotionTemp> resultList = new ArrayList<>();
        for (ZhenHuanPromotionInfo zhenHuanPromotionInfo : infoList) {
            ZhenHuanProto.ZhenHuanPromotionTemp.Builder builder = parsePromotionTemp(zhenHuanPromotionInfo);
            resultList.add(builder.build());
        }
        return resultList;
    }

    public static ZhenHuanPromotionInfo parsePromotionInfo(ZhenHuanProto.ZhenHuanPromotionTemp temp) {
        ZhenHuanPromotionInfo promotionInfo = new ZhenHuanPromotionInfo();
        promotionInfo.setUserId(temp.getUserId());
        promotionInfo.setRank(temp.getRank());
        promotionInfo.setValue(new BigInteger(temp.getValue()));
        promotionInfo.setParam(temp.getParam());
        promotionInfo.setLastUpdateTime(temp.getLastUpdateTime());
        return promotionInfo;
    }

    public static ZhenHuanProto.ZhenHuanSecondProcessUserSyncMsg.Builder parseSecondProcessUserSyncMsg(UserZhenHuanSecondProcessData userData) {
        ZhenHuanProto.ZhenHuanSecondProcessUserSyncMsg.Builder builder = ZhenHuanProto.ZhenHuanSecondProcessUserSyncMsg.newBuilder();
        builder.setActivityId(userData.getActivityId());
        builder.setLevel(userData.getLevel());
        builder.setLoveDegree(userData.getLoveDegree());
        builder.setPrestigeDegree(userData.getPrestigeDegree());
        builder.setPower(userData.getPower());
        builder.setIsWorship(userData.isWorship());
        builder.setAble(userData.isAble());
        return builder;
    }

    public static ZhenHuanProto.ZhenHuanSecondProcessUserPlaceTemp.Builder parsePlaceTemp(UserZhenHuanGoingOutData userZhenHuanGoingOutData) {
        ZhenHuanProto.ZhenHuanSecondProcessUserPlaceTemp.Builder builder = ZhenHuanProto.ZhenHuanSecondProcessUserPlaceTemp.newBuilder();
        builder.setPlaceId(userZhenHuanGoingOutData.getPlaceId());
        builder.setProgress(userZhenHuanGoingOutData.getProgress());
        builder.setAmount(userZhenHuanGoingOutData.getAmount());
        return builder;
    }

    public static List<ZhenHuanProto.ZhenHuanSecondProcessUserPlaceTemp> parsePlaceTempList(List<UserZhenHuanGoingOutData> infoList) {
        List<ZhenHuanProto.ZhenHuanSecondProcessUserPlaceTemp> resultList = new ArrayList<>();
        for (UserZhenHuanGoingOutData userZhenHuanGoingOutData : infoList) {
            ZhenHuanProto.ZhenHuanSecondProcessUserPlaceTemp.Builder builder = parsePlaceTemp(userZhenHuanGoingOutData);
            resultList.add(builder.build());
        }
        return resultList;
    }
}
